/**
 * 匠言知识付费v2.0.0
 * Author: 山西匠言网络科技有限公司
 * 这不是一个免费软件，它受限于许可条款，你可以访问https://www.zsfzxkc.cn/获取更多详细信息。
 * This is not a free software, it under the license terms, you can visit https://www.zsffzxkc.cn/ get more details.
 */
<template>
	<view class="container">
		
		<view class="title">
			<text v-if="btnnum == 0">您的一级直推好友为{{contents.length}}人</text>
			<text v-if="btnnum == 1">您的二级间推好友为{{contents.length}}人</text>
		</view>
		
		<view class="team">
			<!-- 团队title -->
			<view class="team-title">
				<view class="team-title-item" v-for="(item, index) in kechengList" :key="index">
					<view @click="teamchange(index)" :class="{btna:btnnum == index}">{{item}}</view>
					<text :class="{_underline: btnnum == index}"></text>
				</view>
			</view>
			
			
			<!-- 团队内容 -->
			<view class="team-content">
				<!-- 直推 -->
				<view class="zhitui" :class="{dis:btnnum == 0}">
					<!-- <view class="table" style="padding: 0 10upx;">
						<t-table @change="change">
							<t-tr>
								<t-th>ID</t-th>
								<t-th>头像</t-th>
								<t-th>昵称</t-th>
								<t-th>是否分销商</t-th>
								<t-th>注册时间</t-th>
							</t-tr>
							<t-tr>
								<t-td>7081</t-td>
								<t-td>1</t-td>
								<t-td style="word-break: break-all;">99q1wWlmQm</t-td>
								<t-td>未激活</t-td>
								<t-td>未激活</t-td>
							</t-tr>
						</t-table>
					</view> -->
					<wyb-table height="auto" ref="table" first-line-fixed="true" :headers="headers" :contents="contents" :url-col="urlCol" />
				</view>
				
				<!-- 间推-->
				<view class="jiantui" :class="{dis:btnnum == 1}">
					<!-- <view class="table" style="padding: 0 10upx;">
						<t-table @change="change">
							<t-tr>
								<t-th>ID</t-th>
								<t-th>头像</t-th>
								<t-th>昵称</t-th>
								<t-th>是否分销商</t-th>
								<t-th>注册时间</t-th>
							</t-tr>
							<t-tr>
								<t-td>7081</t-td>
								<t-td>1</t-td>
								<t-td style="word-break: break-all;">99q1wWlmQm</t-td>
								<t-td>未激活</t-td>
								<t-td>未激活</t-td>
							</t-tr>
						</t-table>
					</view> -->
					<wyb-table height="auto" ref="table" first-line-fixed="true" :headers="headers" :contents="contents" :url-col="urlCol" />
				</view>
				
			</view>
		</view>
		
	</view>
</template>

<script>
	import wybTable from '../components/wyb-table/wyb-table.vue'
	import { postMyTeam } from '@/request/fenxiao'
	export default {
		components: {wybTable},
		data() {
			return {
				kechengList: ['直推', '间推'],
				btnnum: 0,
				headers: [
					{label: 'UID',key: 'id'},
					{label: '昵称',key: 'nickname'},
					{label: '用户类型',key: 'viptype'}, 
					{label: '注册时间',key: 'zctime'}],
				contents: [],
				urlCol: [{
						type: 'route',
						key: 'url'
				}, {
						type: 'http',
						key: 'link'
				}]
			}
		},
		onShareAppMessage(res) {
			let path = getCurrentPages()
			let path_share = path[0].$page.fullPath
			let path_title = path[0].data.title
			let userinfo = uni.getStorageSync('userinfo')
			let base_set = uni.getStorageSync('base_set')
			if(userinfo.uid=='' || !userinfo.uid){
				uni.navigateTo({
					url:'../login/login'
				})
				return {
					title: '请先登录后再分享给好友',
					path: ''
				}
			}else{
				if (res.from === 'button') {
					
				}
				return {
					title: base_set.title,
					path: `${path_share}?pid=${userinfo.uid}`
				}
			}
		},
		onLoad() {
			this.teamchange(this.btnnum)
		},
		methods: {
			teamchange(e) {
				this.btnnum = e
				let userinfo = uni.getStorageSync('userinfo')
				postMyTeam({uid: userinfo.uid, type: e}).then(res => {
					console.log(res)
					this.contents = res.data.data
				})
			}
		}
	}

</script>

<style lang="less" scoped>
	
	.title {
		height: 100upx;
		background-color: blue;
		display: flex;
		align-items: center;
		text {
			font-size: 34upx;
			font-weight: 700;
			color: #fff;
			margin-left: 20upx;
		}
	}
	
	
// 团队部分
.team {
	&-title{
		height: 125upx;
		background-color: #fff;
		padding-top: 45upx;
		box-sizing: border-box;
		display: flex;
		justify-content: space-around;
		&-item {
			flex: 1;
			display: flex;
			flex-direction: column;
			align-items: center;
			view {
			font-size: 30upx;
			color: #575757;
			}
			.btna { // 需要追加到view上的class
				font-weight: 700;
				color: #131313;
			}
			._underline { // 需要追加到view下方的下划线class
				width: 70upx;
				height: 7upx;
				background-color: #2f77ff;
				border-radius: 5upx;
				margin-top: 15upx;
			}
		}
		
	}
	
	&-content {
		// 讲师介绍
		.zhitui {
			display: none;
		}
		
		// 作品
		.jiantui {
			display: none;
		}
		
		.dis{
			display: block;
		}
	}
}
</style>
